package com.tansun.easycare.core.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import net.sf.ehcache.CacheManager;
import net.sf.ehcache.config.CacheConfiguration;
import net.sf.ehcache.config.PersistenceConfiguration;



@Configuration
public class EhcacheConfig {
	
    @Bean
    public CacheManager getCacheManager(){
        
    	CacheConfiguration config = new CacheConfiguration();
        config.setName("sysCache");
        config.setMaxEntriesLocalDisk(1000l);
        config.setMaxEntriesLocalHeap(5000l);
        config.setEternal(false);
        config.setDiskSpoolBufferSizeMB(50);
        config.setMemoryStoreEvictionPolicy("LFU");
        config.addPersistence(new PersistenceConfiguration().strategy(PersistenceConfiguration.Strategy.LOCALTEMPSWAP));

        net.sf.ehcache.config.Configuration configuration = new net.sf.ehcache.config.Configuration();
        configuration.addCache(config);
        CacheManager cacheManager = CacheManager.newInstance(configuration);

        return cacheManager;
    }

}
